class RateLimiter {
    constructor(options = {}) {
      this.interval = options.interval || 1000; // 默认1秒
      this.lastRequestTime = 0;
    }
    
    async wait() {
      const now = Date.now();
      const elapsed = now - this.lastRequestTime;
      
      if (elapsed < this.interval) {
        const waitTime = this.interval - elapsed;
        await new Promise(resolve => setTimeout(resolve, waitTime));
      }
      
      this.lastRequestTime = Date.now();
    }
  }
  
  module.exports = RateLimiter;  